<?php namespace App\Services\CarouselsService;
/**
 * 轮播图api
 *
 * 轮播图service
 *
 * @author    zhouchao <zhouchao@yunys.com.cn>
 * @copyright 2016 QuanZhouYunYiShang Inc.
 */
use App\Services\BaseService;
use App\Services\ProductTempService\ProductTempTool;
class CarouselsService extends BaseService{

    public function __construct()
    {

    }

    public function getList(){
        $this->setParameter(array(
            'table'=>'carousels',
            'where'=>array(
                array('state','=',1),
                array('begin','<',time()),
                array('end','>',time())
            ),
            'select'=>array('carousel_id','carousel_image','carousel_type','app_id','resource_id','url'),
            'sort'=>'desc',
            'order'=>'sort'
        ));
        $carousels = $this->getAll()->toArray();
        foreach($carousels as $carousel){
            $carousel->carousel_image = $this->setImagePath($carousel->carousel_image);
            $carousel->product_temp_category_id = ProductTempTool::getCategoryIdByProductTempId($carousel->resource_id);
//            if($carousel->carousel_type == 2){
//                $carousel->product_temps = array('wait'=>'模板的参数');
//            }else{
//                $carousel->product_temps = (object)array();
//            }
        }
        return $carousels;
    }
}